Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <script> function getOption() { var obj = document.getElementById("mySelect"); document.getElementById("demo").innerHTML = obj.options[obj.selectedIndex].text; } </script> </head> <body> <form> Select your favorite fruit: <select id="mySelect"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> </select> <br><br> <input type="button" onclick="getOption()" value="Click Me!"> </form> <p id="demo"></p> </body> <!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=try_dom_select_option by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:36:54 GMT --> </html>
Result:
Try it Yourself - © w3schools.com